#include "../menu.h"
#include <aw_playlist2.h>
#include "../../user.h"
//#include "../aw_sys_app.h"
#include "FileTypeSelectEvent.h"
#include "fs_playlist.h"
#include "filenav.h"
#include "LogoEvent.h"
#include "aw_gui_app.h"
#include "aw_AVI_app.h"
#include "aw_RM_app.h"
#include "aw_TXT_app.h"
#include "aw_VOB_app.h"
#include "aw_GPLAYER_app.h"
#include "ctrlconvert.h"
#include "NetmenuSetupEvent.h"
#include "WinConfirmEvent.h" 
#include "DebugEvent.h" 

#ifdef TXT_PLAYER
  #define SHOW_FILETYPE_NUM 5
#else 
  #define SHOW_FILETYPE_NUM 4
#endif 

extern INT8U keep_current_index;
extern INT8U filelist_show_flag;
extern INT8U ShowSixPicFlag;
extern INT8U FileListOnShowFlag;
extern INT8U	WinTypeChoice;
extern INT32U gGetFileType ;
extern INT32U ONLYDIR_FLAG;
extern unsigned filelist_music[MAX_FILE_NODIR];
extern unsigned filelist_video[MAX_FILE_NODIR];
#ifdef TXT_PLAYER
extern unsigned filelist_txt[MAX_FILE_NODIR];
#endif
extern char CurDriver[10];
extern int MultiMenuToSingle;

INT32U NODIR_FLAG = 0;  //0 for with dir, 1 for playing music without dir, 2 for playing video without dir.
INT32U cur_filetype_flag = 0;
INT8U gcPicFileExist=0;
INT8U gcAudioFileExist=0;
INT8U gcVideoFileExist=0;

INT32S AutoRunWhenSelectAudioOrVideo(INT8U SelType);
INT32S JudgeCurrDirHaveMediaOrNull(INT8U MediaType);
extern unsigned char osdsettpval(unsigned char num,unsigned char level);
extern void ClearPanelAction(INT32U *key_value);
extern int check_media_file_exist(char* path_name ,unsigned media_type,int search_way);

void change_window_no_file(void)
{

		CloseMediaPlaybackApp(0xff);
		AWGUISendNMMessage(MEDIA_GUI, NM_PLAY_GENERAL, (INT32U)0);
}

void UpdateFileTypeDisp(PHWND hwnd,INT8U focus_flag)//refresh highlight of filetype
{

	INT8U i;
	for(i=0;i<SHOW_FILETYPE_NUM;i++)
	{
        switch(i)
        {
        #ifdef TXT_PLAYER
            case 0:
                if (i == focus_flag)
                {
                    hwnd->draw_info[0].draw_data = (INT32U)ICON_MOVIE_FOCUS;
                    hwnd->draw_info[5].draw_data = (INT32U)0; //ICON_DEVICENAME_BCK;
                    hwnd->draw_info[10].draw_data = (INT32U)MOVIE_STR;
                }
                else
                {
                    hwnd->draw_info[0].draw_data = (INT32U)ICON_MOVIE_LOSE;
                    hwnd->draw_info[5].draw_data = (INT32U)0; //ICON_FILETYPE_NAME_BLANK;
                    hwnd->draw_info[10].draw_data = (INT32U)0;
                }
                break;
            case 1:
                if (i == focus_flag)
                {
                    hwnd->draw_info[1].draw_data = (INT32U)ICON_MUSIC_FOCUS;
                    hwnd->draw_info[6].draw_data = (INT32U)0; //ICON_DEVICENAME_BCK;
                    hwnd->draw_info[11].draw_data = (INT32U)MUSIC_STR;
                }
                else
                {
                    hwnd->draw_info[1].draw_data = (INT32U)ICON_MUSIC_LOSE;
                    hwnd->draw_info[6].draw_data = (INT32U)0; //ICON_FILETYPE_NAME_BLANK;
                    hwnd->draw_info[11].draw_data = (INT32U)0;
                }
                break;
            case 2:
                if (i == focus_flag)
                {
                    hwnd->draw_info[2].draw_data = (INT32U)ICON_PHOTO_FOCUS;
                    hwnd->draw_info[7].draw_data = (INT32U)0; //ICON_DEVICENAME_BCK;
                    hwnd->draw_info[12].draw_data = (INT32U)PHOTO_STR;
                }
                else
                {
                hwnd->draw_info[2].draw_data = (INT32U)ICON_PHOTO_LOSE;
                hwnd->draw_info[7].draw_data = (INT32U)0; //ICON_FILETYPE_NAME_BLANK;
                hwnd->draw_info[12].draw_data = (INT32U)0;
                }
                break;
            case 3:
                if (i == focus_flag)
                {
                    hwnd->draw_info[3].draw_data = (INT32U)ICON_TXT_FOCUS;
                    hwnd->draw_info[8].draw_data = (INT32U)0; //ICON_DEVICENAME_BCK;
                    hwnd->draw_info[13].draw_data = (INT32U)TXT_STR;
                }
                else
                {
                    hwnd->draw_info[3].draw_data = (INT32U)ICON_TXT_LOSE;
                    hwnd->draw_info[8].draw_data = (INT32U)0; //ICON_FILETYPE_NAME_BLANK;
                    hwnd->draw_info[13].draw_data = (INT32U)0;
                }
                break;
            case 4:
                if (i == focus_flag)
                {
                    hwnd->draw_info[4].draw_data = (INT32U)ICON_FILE_FOCUS;
                    hwnd->draw_info[9].draw_data = (INT32U)0; //ICON_DEVICENAME_BCK;
                    hwnd->draw_info[14].draw_data = (INT32U)FILE_STR;
                }
                else
                {
                    hwnd->draw_info[4].draw_data = (INT32U)ICON_FILE_LOSE;
                    hwnd->draw_info[9].draw_data = (INT32U)0; //ICON_FILETYPE_NAME_BLANK;
                    hwnd->draw_info[14].draw_data = (INT32U)0;
                }
                break;
            default:
                break;
        #else     	
            case 0:
                if(i == focus_flag)
                {
                    hwnd->draw_info[0].draw_data = (INT32U)ICON_MOVIE_FOCUS;
			        hwnd->draw_info[4].draw_data = (INT32U)0;//ICON_DEVICENAME_BCK;
			        hwnd->draw_info[8].draw_data = (INT32U)MOVIE_STR;
                }
                else
                {
                    hwnd->draw_info[0].draw_data = (INT32U)ICON_MOVIE_LOSE;
		            hwnd->draw_info[4].draw_data = (INT32U)0;//ICON_FILETYPE_NAME_BLANK;
		            hwnd->draw_info[8].draw_data = (INT32U)0;
                }
                break;
            case 1:
                if(i == focus_flag)
                {
                    hwnd->draw_info[1].draw_data = (INT32U)ICON_MUSIC_FOCUS;
                    hwnd->draw_info[5].draw_data = (INT32U)0;//ICON_DEVICENAME_BCK;
                    hwnd->draw_info[9].draw_data = (INT32U)MUSIC_STR;
                }
                else
                {
                    hwnd->draw_info[1].draw_data = (INT32U)ICON_MUSIC_LOSE;
			        hwnd->draw_info[5].draw_data = (INT32U)0;//ICON_FILETYPE_NAME_BLANK;
			        hwnd->draw_info[9].draw_data = (INT32U)0;
                }
                break;
            case 2:
                if(i == focus_flag)
                {
                    hwnd->draw_info[2].draw_data = (INT32U)ICON_PHOTO_FOCUS;
                    hwnd->draw_info[6].draw_data = (INT32U)0;//ICON_DEVICENAME_BCK;
                    hwnd->draw_info[10].draw_data = (INT32U)PHOTO_STR;
                }
                else
                {
                    hwnd->draw_info[2].draw_data = (INT32U)ICON_PHOTO_LOSE;
                    hwnd->draw_info[6].draw_data = (INT32U)0;//ICON_FILETYPE_NAME_BLANK;
                    hwnd->draw_info[10].draw_data = (INT32U)0;
                }
                break;
            case 3:
                if(i == focus_flag)
                {
                    hwnd->draw_info[3].draw_data = (INT32U)ICON_FILE_FOCUS;
		            hwnd->draw_info[7].draw_data = (INT32U)0;//ICON_DEVICENAME_BCK;
		            hwnd->draw_info[11].draw_data = (INT32U)FILE_STR;
                }
                else
                {
                    hwnd->draw_info[3].draw_data = (INT32U)ICON_FILE_LOSE;
		            hwnd->draw_info[7].draw_data = (INT32U)0;//ICON_FILETYPE_NAME_BLANK;
		            hwnd->draw_info[11].draw_data = (INT32U)0;
                }
                break;
            default:
                break;
       #endif         
        }
    }
}


INT32S WinFileTypeSelectOnShow(PHWND hwnd, INT32S lpParam)
{
	filelist_show_flag = 0;
	osdsettpval(3,0xf); 
    return 0 ;
}

INT32S WinFileTypeSelectInfoOnShow(PHWND hwnd, INT32S lpParam)
{
	UpdateFileTypeDisp(hwnd,cur_filetype_flag);
	return 0 ;
}

INT32S WinFileTypeSelectInfoOnKeyPress(PHWND hwnd, INT32S lpParam)
{
 	INT32U *key_value = (INT32U *)lpParam ;
	INT8U temp_flag;
	INT8U ret = 0;
	int PicExsit;
//	FileListPlayStatus = 0;
	
	FileNavCD(CurDriver) ;
	
	switch(*key_value){
		ONLYDIR_FLAG = 0;
		case UOP_ENTER:
//		 dev_win_flag=0;
 			switch(cur_filetype_flag)
			{
				case 0:              //video
					if(JudgeCurrDirHaveMediaOrNull(VIDEO) == 0)
					{
						GUIHideWindow(WinFileTypeSelect);
						ShowWinConfirm(CONFIRM_NOFILE);
					}
					else
					{
						NODIR_FLAG = 2;
						WinTypeChoice = VIDEO ;
						Setkeep_current_index(0);
						GUIShowWindow(WinLogo);
					}
					break;
		              
				case 1:         //music
					if(JudgeCurrDirHaveMediaOrNull(AUDIO) == 0)
					{
						GUIHideWindow(WinFileTypeSelect);
						ShowWinConfirm(CONFIRM_NOFILE);
					}
					else
					{
						NODIR_FLAG = 1;
						WinTypeChoice = AUDIO ;
						Setkeep_current_index(0);
						GUIShowWindow(WinLogo);
					}
					break;
                case 2:         //photo
					NODIR_FLAG = 0;
                    WinTypeChoice = PHOTO;
                #ifdef FILE_SORTING
                    FileNavSetDefaultSortType(FILENAV_SORT_NONE, FILENAV_SORT_NUM);
                #endif
	//			  if(gcVideoFileExist)
					PicExsit=check_media_file_exist(CurDriver,MEDIA_PIC,DIR_SEARCH_DEPTH|0x1);
					if(PicExsit==1){
                        set_current_logo_type(1); 
						GUIShowWindow(Win15Pic);
					}
                    else
					{
                        GUIHideWindow(WinFileTypeSelect);
                        ShowWinConfirm(CONFIRM_NOFILE);
					}
					break;
            #ifdef TXT_PLAYER					
                case 3:         //text
					if(JudgeCurrDirHaveMediaOrNull(TXT) == 0)
					{
						GUIHideWindow(WinFileTypeSelect);
						ShowWinConfirm(CONFIRM_NOFILE);
					}
					else
					{
						NODIR_FLAG = 3;
						WinTypeChoice = TXT ;
						Setkeep_current_index(0);
						GUIShowWindow(WinLogo);
                        //WinTypeChoice = TXT; //cloudy  
                        //gGetFileType = MEDIA_TXT | NAV_IS_DIR;
                        //gGetFileType = MEDIA_TXT;
                        //FileListOnShowFlag = 0;
                        //GUIShowWindow(WinFileList);
				    }
                    break;
                case 4:         //file
                    NODIR_FLAG = 0;
					WinTypeChoice=0;
                    gGetFileType = AW_PIC_LIST | AW_AUDIO_LIST | AW_VIDEO_LIST |MEDIA_TXT | NAV_IS_DIR;
                    FileListOnShowFlag = 0;
                    GUIShowWindow(WinFileList);
                    break;
            #else 
                case 3:         //file
                    NODIR_FLAG = 0;	
					WinTypeChoice=0;
                    gGetFileType = AW_PIC_LIST | AW_AUDIO_LIST | AW_VIDEO_LIST |MEDIA_TXT | NAV_IS_DIR;
                    FileListOnShowFlag = 0;
                    GUIShowWindow(WinFileList);
                    break;
            #endif 
                default:
                    break;
            }
        break;

		case UOP_STOP:
		case UOP_RESUME:
		case UOP_HOME:
	    	//char * device_name=(char*)AVMem_umalloc(40);
	    	//unsigned port;
	    	//FileNavGetMountPointDeviceName(CurDriver,device_name,40);
	    	//port=GetUSBPort(device_name);
	    	//AVMem_free(device_name);
	    	//ShowVolumeCheck_Filetype(port);
			FileNavCD(CurDriver);
			GUIShowWindow(WinDeviceSelect);

			break;

	    case UOP_LEFT:
		    temp_flag = cur_filetype_flag;
		    if(cur_filetype_flag == 0)
		        cur_filetype_flag=SHOW_FILETYPE_NUM-1;  
		    else
		        cur_filetype_flag--;
	        UpdateFileTypeDisp(hwnd, cur_filetype_flag);
	        AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,temp_flag);
		    AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,cur_filetype_flag);
	    #ifdef TXT_PLAYER
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 5);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 6);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 7);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 8);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 9);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, cur_filetype_flag + 10);
        #else 
		    AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,4);
		    AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,5);
		    AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,6);
		    AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,7);
            AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,cur_filetype_flag+8);
        #endif 
            AWPostMessage(hwnd,WM_PAINT_FINISH,0);
            break;
        case UOP_RIGHT:
		    temp_flag = cur_filetype_flag;
	        if(cur_filetype_flag >= (SHOW_FILETYPE_NUM-1))
		        cur_filetype_flag=0; 
		    else
			    cur_filetype_flag++;
            UpdateFileTypeDisp(hwnd, cur_filetype_flag);
            AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,temp_flag);
            AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,cur_filetype_flag);
        #ifdef TXT_PLAYER
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 5);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 6);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 7);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 8);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 9);
            AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, cur_filetype_flag + 10);
        #else 
            AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,4);
            AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,5);
            AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,6);
            AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,7);
            AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,cur_filetype_flag+8);
        #endif 
            AWPostMessage(hwnd,WM_PAINT_FINISH,0);
            break;
			case UOP_END_PAUSE:
				keep_current_index = 0;
				switch(cur_filetype_flag)
				{
					case 0:
						*key_value = UOP_NOP ;
						if(JudgeCurrDirHaveMediaOrNull(VIDEO) == 0)
						{
							GUIHideWindow(WinFileTypeSelect);
							ShowWinConfirm(CONFIRM_NOFILE);
						}
						else
							AutoRunWhenSelectAudioOrVideo(VIDEO);
						
						break;
												
					case 1:
						*key_value = UOP_NOP ;
						if(JudgeCurrDirHaveMediaOrNull(AUDIO) == 0)
						{
							GUIHideWindow(WinFileTypeSelect);
							ShowWinConfirm(CONFIRM_NOFILE);
						}
						else
						if(AutoRunWhenSelectAudioOrVideo(AUDIO)){
							GUIHideWindow(WinFileTypeSelect);
							GUIShowWindow(WinLogo);
						}
						break;
					
					case 2:         //photo
						NODIR_FLAG = 0;
              			PicExsit=check_media_file_exist(CurDriver,MEDIA_PIC,0x300|0x1);
						if(PicExsit==1)
						{
							SetPicRunStatus(0);
							ShowSixPicFlag=0;
							GUIHideWindow(WinFileTypeSelect);
							display_multi_pic();
							//AWPICKeyDo(*key_value) ;
							MultiMenuToSingle=1; 
						} 
						else         
						{
							GUIHideWindow(WinFileTypeSelect);
							ShowWinConfirm(CONFIRM_NOFILE);
						}
						break;
                #ifdef TXT_PLAYER					
                    case 3:         //text
                        NODIR_FLAG = 0;					
                        WinTypeChoice = TXT; //cloudy  
                        gGetFileType = MEDIA_TXT | NAV_IS_DIR;
                        FileListOnShowFlag = 0;
                        GUIShowWindow(WinFileList);
                        break;
                    case 4:         //file
                        NODIR_FLAG = 0;
    					WinTypeChoice=0;
                        gGetFileType = AW_PIC_LIST | AW_AUDIO_LIST | AW_VIDEO_LIST |MEDIA_TXT | NAV_IS_DIR;
                        FileListOnShowFlag = 0;
                        GUIShowWindow(WinFileList);
                        break;
                #else 
                    case 3:         //file
                        NODIR_FLAG = 0;	
    					WinTypeChoice=0;
                        gGetFileType = AW_PIC_LIST | AW_AUDIO_LIST | AW_VIDEO_LIST |MEDIA_TXT | NAV_IS_DIR;
                        FileListOnShowFlag = 0;
                        GUIShowWindow(WinFileList);
                        break;
                #endif 
					default:
						break;
				}
			default:
				break;
	}
	ClearPanelAction(key_value) ;
    return 0 ;
}


INT32S AutoRunWhenSelectAudioOrVideo(INT8U SelType)
{
	INT32U app_type, item_type;
	
	Playlist_t *Videoplaylist=NULL;
	Playlist_t *Audioplaylist=NULL;
#ifdef TXT_PLAYER
	Playlist_t *Txtplaylist=NULL;
    PlaylistItem_t *item;
	CHARSTR extname[MAX_EXTNAME_LEN];
	PlaylistStatus_t status;
#endif	
	if(SelType == VIDEO){

		Videoplaylist = (Playlist_t *)fs_playlist_create_nodir(
								(unsigned char *)CurDriver, 
								AW_VIDEO_LIST&NAV_PATH_TYPE,
								PLAYLIST_TYPE_VIDEO, 
								0, 
								0,
								&app_type
								);	

		if(Videoplaylist){
			if(CheckMediaPlaybackApp()){
				CloseMediaPlaybackApp(0xff);
			}
			
				NODIR_FLAG = 2 ;
				WinTypeChoice = VIDEO ;
				Setkeep_current_index(0);
				
				item_type = GetMediaType((char *)filelist_video[0]) ;
				
				switch(item_type){
					
					case MEDIA_AVI:
						if(RunAVIPlayer(Videoplaylist))
							AWPlaylistDelete2(Videoplaylist);
						return 1 ;
#ifdef SUPPORT_RM
					case MEDIA_REAL:
						if(RunRMPlayer(Videoplaylist))
							AWPlaylistDelete2(Videoplaylist);
						return 1 ;
#endif
//					case MEDIA_MPEG1:
					case MEDIA_MPEG2:
						if(RunVOBPlayer(Videoplaylist))
							AWPlaylistDelete2(Videoplaylist);
						return 1 ;
						
					case MEDIA_MOV:
						if (RunGPlayer(Videoplaylist))
							AWPlaylistDelete2(Videoplaylist);
						return 1 ;

					default:
						return 0 ;
				}	
		}
	}
	else if(SelType == AUDIO){
		Audioplaylist = fs_playlist_create_nodir(
							(unsigned char *)CurDriver, 
							AW_AUDIO_LIST&NAV_PATH_TYPE,
							PLAYLIST_TYPE_AUDIO, 
							0, 
							0,
							&app_type
							);
		
		if(Audioplaylist){
			if(CheckMediaPlaybackApp())
				CloseMediaPlaybackApp(0xff);

				NODIR_FLAG = 1;
				WinTypeChoice = AUDIO ;
				extern Music_Play_flag ;
				Music_Play_flag = 1 ;
				Setkeep_current_index(0);

			if(RunGPlayer(Audioplaylist)){
				AWPlaylistDelete2(Audioplaylist);
			}
			return 1 ;
		}
	}
#ifdef TXT_PLAYER
	else if(SelType == TXT)
	{
        Txtplaylist = fs_playlist_create_nodir(
							(unsigned char *)CurDriver, 
							MEDIA_TXT&NAV_PATH_TYPE,
							PLAYLIST_TYPE_IMAGE, 
							0, 
							0,
							&app_type
							);
        if(Txtplaylist)
        {
            NODIR_FLAG = 3;
            status = AWGetStartPlaylistItem2(Txtplaylist);
            if(status != PLAYLIST_STATUS_ASYNCH) 
            {
                //AWTXTQuitProcess(0) ;
                AWTXTKeyDo(UOP_STOP,0);
                AWPlaylistDelete2(Txtplaylist);
                return 0;
            }
            while(1)
            {
    	        item = AWGetCurrentPlaylistItem2(Txtplaylist);
                if(item)
                {
                    GetFileExName(item->location, extname) ;
                    if(!(strcmp("IMG",(char*)extname)))
                    {
                        status = AWGetNextPlaylistItem2(Txtplaylist);
                        if(status != PLAYLIST_STATUS_ASYNCH) 
                        {                                   
                            AWPlaylistDelete2(Txtplaylist);
                            //AWTXTQuitProcess(0) ;
                            AWTXTKeyDo(UOP_STOP,0);
                            return 0;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    //AWTXTQuitProcess(0) ;
                    AWTXTKeyDo(UOP_STOP,0);
                    return 0;
                }
            }
            WinTypeChoice = TXT ;
            if (CurrentOsdSize == OsdSize576i || CurrentOsdSize == OsdSize576p || CurrentOsdSize == OsdSize576iCVBS)
                PlayTxtFile(item->location, TXT_PLAY_TXT, TXT_DISPLAY_HIGH_IN_LINE, 640);
        #ifdef TV_MODE_1080P
            else if (CurrentOsdSize == OsdSize1080p)
                PlayTxtFile(item->location, TXT_PLAY_TXT, TXT_DISPLAY_HIGH_IN_LINE, 1160);
        #endif
        #ifdef TV_MODE_720P
            else if (CurrentOsdSize == OsdSize720p)
                PlayTxtFile(item->location, TXT_PLAY_TXT, TXT_DISPLAY_HIGH_IN_LINE, 1160);
        #endif
            else
                PlayTxtFile(item->location, TXT_PLAY_TXT, TXT_DISPLAY_HIGH_IN_LINE, 660);
            //ReloadLogo(Logo_keyboard, sizeof(Logo_keyboard));
            GUIShowWindow(WinDebug) ;
            FileListInitData();
            SetGetFileType(MEDIA_TXT);
            AWSetFileList(AWFindWinCtrlByName(FileListView), NULL, NULL);
        }
	}
#endif
	return 0 ;
}

INT32S JudgeCurrDirHaveMediaOrNull(INT8U MediaType)
{
	CHARSTR*  path_name;
	INT32S search_way = DIR_SEARCH_DEPTH|0x1;   //0x0A01;

	path_name = CurDriver;//FileNavGetCurrDir();
	
	if (MediaType == AUDIO){
		memset(filelist_music, 0, MAX_FILE_NODIR*sizeof(unsigned));
		fs_filelist_create_nodir(path_name , SHOW_LONG_FILE_NAME, PLAYLIST_TYPE_AUDIO, search_way);
		if(filelist_music[0] == 0)
			return 0 ;
		else
			return AUDIO ;
	}
	else if (MediaType == VIDEO){
		memset(filelist_video, 0, MAX_FILE_NODIR*sizeof(unsigned));
		fs_filelist_create_nodir(path_name , SHOW_LONG_FILE_NAME, PLAYLIST_TYPE_VIDEO, search_way);
		if(filelist_video[0] == 0)
			return 0 ;
		else
			return VIDEO ;
	}
#ifdef TXT_PLAYER
	else if (MediaType == TXT){
		memset(filelist_txt, 0, MAX_FILE_NODIR*sizeof(unsigned));
		fs_filelist_create_nodir(path_name , SHOW_LONG_FILE_NAME, PLAYLIST_TYPE_IMAGE, search_way);
		if(filelist_txt[0] == 0)
			return 0 ;
		else
			return TXT ;
	}
#endif
	else
		return 0 ;
}
